package com.wanlian.router.storage;

import com.smart.android.storage.DataStorageSystem;
import com.wanlian.router.Frame;

/**
 * Created by Hyu on 2018/9/12.
 * Email: fvaryu@163.com
 */
public interface UserData {

    UserData DEFAULT = new UserData() {


        @Override
        public long getUserId() {
            return DataStorageSystem.get(Frame.getInstance().getAppContext()).readLong("_user.id");
        }

        @Override
        public void setUserId(long id) {
            DataStorageSystem.get(Frame.getInstance().getAppContext()).write("_user.id", id);
        }

        @Override
        public void setOrganizeId(long id) {
            DataStorageSystem.get(Frame.getInstance().getAppContext()).write("_user.orgId", id);
        }

        @Override
        public long getOrganizeId() {
            return DataStorageSystem.get(Frame.getInstance().getAppContext()).readLong("_user.orgId");
        }

        @Override
        public void setDepartmentId(long id) {
            DataStorageSystem.get(Frame.getInstance().getAppContext()).write("_user.dpId", id);
        }

        @Override
        public long getDepartmentId() {
            return DataStorageSystem.get(Frame.getInstance().getAppContext()).readLong("_user.dpId");
        }

        @Override
        public String getSessionId() {

            return DataStorageSystem.get(Frame.getInstance().getAppContext()).readString("_sessionId");
        }

        @Override
        public void setSessionId(String sessionId) {
            DataStorageSystem.get(Frame.getInstance().getAppContext()).write("_sessionId", sessionId);
        }

        @Override
        public void clean() {
            DataStorageSystem.get(Frame.getInstance().getAppContext()).clean();
        }
    };


    long getUserId();
    void setUserId(long id);

    void setOrganizeId(long id);
    long getOrganizeId();

    void setDepartmentId(long id);
    long getDepartmentId();

    String getSessionId();

    void setSessionId(String sessionId);

    void clean();

}
